module comm.UploadToken;

class UploadToken
{
    string user_id;
    string token;
    ulong time;
}

class UploadedFile
{
    string user_id;
    string filename;
    string mimetype;
    string url;
    ulong time;
}

string rndStr(short length = 32)
{
    import std.random : uniform;

    string code;

    if(length < 1 || length > 64)
    {
        throw new Exception("length range 1 ~ 64");
    }

    string sample = "qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM";
    int sampleLen = 42;
    for(short i = 0; i < length; i++)
    {
        code ~= sample[uniform(0, sampleLen - 1)];
    }

    return code;
}
